﻿<Grid x:Class="httpExplorer.Xaml.OutputGrid"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:Xaml="clr-namespace:httpExplorer.Xaml" xmlns:System="clr-namespace:System;assembly=mscorlib"
        DataContext="{Binding OutputViewModel, Source={StaticResource Locator}}">
    <Grid>
        <Grid.Resources>

        </Grid.Resources>
        <Grid.RowDefinitions>
            <RowDefinition Height="100"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <ListView Grid.Row="0"  ItemsSource="{Binding ResponsesCollection}" SelectedItem="{Binding SelectedWebReponse, Mode=OneWayToSource}">
            <ListView.Resources>
                <Xaml:ResponseCodeToNumericConverter x:Key="responseCodeToNumericConverter"/>
            </ListView.Resources>
            <ListView.View>
                <GridView>
                    <GridViewColumn Width="auto" Header=" Time " 
                                    DisplayMemberBinding="{Binding Time}" />
                    <GridViewColumn Width="auto" Header=" Code " 
                                    DisplayMemberBinding="{Binding Code}" />
                    <GridViewColumn Width="150" Header=" Description " 
                                    DisplayMemberBinding="{Binding Description}" />
                    <GridViewColumn Width="500" Header=" URL " 
                                    DisplayMemberBinding="{Binding Url}" />
                </GridView>
            </ListView.View>
        </ListView>
        <GridSplitter
            HorizontalAlignment="Stretch" 
            VerticalAlignment="Top" 
            Grid.Row="1" 
            ResizeBehavior="PreviousAndNext"
            Height="10" 
            Background="Transparent"
            Margin="0,3"
            Style="{StaticResource gridSplitterStype}" />
        <Grid Grid.Row="2">
            <TabControl  DataContext="{Binding SelectedWebReponse}">
                <TabItem Header="Response">
                    <ScrollViewer >
                        <StackPanel>
                            <Expander 
                                Header="Response Headers" 
                                VerticalAlignment="Top"
                                IsExpanded="true" 
                                >
                                <Expander.Content>
                                    <ListView  ItemsSource="{Binding ResponseHeaders}">
                                        <ListView.View>
                                            <GridView>
                                                <GridViewColumn Width="auto" Header=" Header " 
                                                        DisplayMemberBinding="{Binding Key}" />
                                                <GridViewColumn Width="auto" Header=" Value " 
                                                        DisplayMemberBinding="{Binding Value}" />
                                            </GridView>
                                        </ListView.View>
                                    </ListView>                      
                                </Expander.Content>
                            </Expander>
                            <Expander 
                                Header="Response Body" 
                                VerticalAlignment="Top" 
                                >
                                <Expander.Content>
                                    <TextBlock
                                        Text="{Binding ResponseBody}"
                                        Margin="4"
                                        FontFamily="Lucida Console"
                                        FontSize="9pt"
                                        />                        
                                </Expander.Content>
                            </Expander>
                        </StackPanel>
                    </ScrollViewer>
                </TabItem>
                <TabItem Header="Request">
                    <ScrollViewer >
                        <StackPanel>
                            <Expander 
                                Header="Request Headers" 
                                VerticalAlignment="Top" 
                                IsExpanded="true" 
                                >
                                <Expander.Content>
                                    <ListView  ItemsSource="{Binding RequestHeaders}">
                                        <ListView.View>
                                            <GridView>
                                                <GridViewColumn Width="auto" Header=" Header " 
                                                        DisplayMemberBinding="{Binding Key}" />
                                                <GridViewColumn Width="auto" Header=" Value " 
                                                        DisplayMemberBinding="{Binding Value}" />
                                            </GridView>
                                        </ListView.View>
                                    </ListView>
                                </Expander.Content>
                            </Expander>
                        </StackPanel>
                    </ScrollViewer>
                </TabItem>
            </TabControl>
        </Grid>
    </Grid> 
</Grid>
